package com.bs.action;

import java.io.IOException;
import java.util.List;

import net.sf.json.JSONArray;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;

import com.bs.bean.Maoli;
import com.bs.service.MaoliService;
@SuppressWarnings("serial")
@ParentPackage("struts-default")
@Namespace("/maoli")
public class MaoliAction extends ActionBase {
	private Maoli maoli;
	private MaoliService maoliService;

	public Maoli getMaoli() {
		return maoli;
	}

	public void setMaoli(Maoli maoli) {
		this.maoli = maoli;
	}

	public MaoliService getMaoliService() {
		return maoliService;
	}

	public void setMaoliService(MaoliService maoliService) {
		this.maoliService = maoliService;
	}
	
	@Action("findAll")
	public void findAll(){
		try {
			List<Maoli> list = this.maoliService.findAll();
			JSONArray maolis = JSONArray.fromObject(list);
			response.getWriter().write(maolis.toString());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	

}
